struct sPointLight
{
	float3 Color;
	float3 Position;
	float FallOff;
	float Range;
};


float3 PointLight_ComputeColor(
	sPointLight instance,
	sMaterial material,
	float3 worldPosition,
	float3 worldNormal,
	float3 directionToCamera)
{
    float3 lightVector = instance.Position - worldPosition;
    float lightDist = length(lightVector);
    float3 directionToLight = normalize(lightVector);
    
    //calculate the intensity of the light with exponential falloff
    float baseIntensity = pow(saturate((instance.Range - lightDist) / instance.Range), instance.FallOff);
    
    float diffuseIntensity = saturate(dot(directionToLight, worldNormal));
	float3 diffuse = diffuseIntensity * instance.Color * material.DiffuseColor;

    //calculate Phong components per-pixel
    float3 reflectionVector = normalize(reflect(-directionToLight, worldNormal));
    
    //calculate specular component
	float3 specular = saturate(instance.Color * material.SpecularColor * pow(saturate(dot(reflectionVector, directionToCamera)), material.SpecularPower));
	
	float3 color = 0;
	color = baseIntensity * (diffuse + specular);
	return color;
}
